/**
 * Created by guodong on 2017/7/17.
 */
'use strict';
angular.module('app')
    .controller('reptileinfoController', [ '$rootScope', '$scope', '$http', '$state','$timeout',
        function($rootScope, $scope, $http, $state, $timeout) {
            $scope.title = '爬虫参数管理';
            $scope.searchParams = { };
            $scope.loading = false;
            $scope.param={};
            $scope.search = function () {
                $scope.loading = true;
                $.ajax({
                    url : $scope.app.project_name+'/hconfig/read/list',
                    data: $scope.searchParams
                }).then(function(result) {
                    console.log(result);
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.pageInfo = result.data;
                            console.log( result.data);
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }

            $scope.search();



            $scope.searchRe = function () {
                $scope.loading = true;
                $scope.searchParams.pageNum = 1;
                $.ajax({
                    url : $scope.app.project_name+'/hconfig/read/list',
                    data: $scope.searchParams
                }).then(function(result) {
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.pageInfo = result.data;
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }



            $scope.clearSearch = function() {
                $scope.searchParams= { };
                $scope.search();
            }



            // 翻页
            $scope.pagination = function (pageNo) {
                $scope.searchParams.pageNum=pageNo;
                $scope.search();
            };


            // 删除
            $scope.deleteByreptile=function (configId,isEnable) {
                    $.ajax({
                        url : $scope.app.project_name+'/hconfig/delete',
                        data: {"configId":configId,"isEnable":isEnable}
                    }).then(function(result) {
                        $scope.loading = false;
                        $timeout(function(){
                            $scope.search();
                        },1000);
                    });
            }
            $scope.getplatselect=function () {
                $.ajax({
                    url : $scope.app.project_name+'/platInfoManage/platInfo/getPlatselect'
                }).then(function(result) {
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.platList = result.data;
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }
            $scope.getplatselect();
        } ]);